package com.definity.toolkit.web.taglib;

import javax.servlet.jsp.JspException;


public class TextAreaTag extends ComponentFormTag {

	private static final long serialVersionUID = -3426306344186292087L;

	private Integer rows;
	private Integer cols;
	
	public TextAreaTag() {

	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}
	
	public void setCols(Integer cols) {
		this.cols = cols;
	}
	
	@Override
	protected String getComponentName() {
		return "textArea";
	}
	
	@Override
	protected String createStartTag(String name, String id, Object value) {
		StringBuilder html = new StringBuilder();
		html.append("<textarea id=\"").append(id).append("\" name=\"").append(id).append("\"");
		if (cols != null)
			html.append(" cols=\"").append(cols).append("\"");
		if (rows != null)
			html.append(" rows=\"").append(rows).append("\"");
		html.append(createStyleClass("common_field"));
		html.append(">");
		return html.toString();
	}
	
	@Override
	protected String createEndTag(String name, String id, Object value) throws JspException {
		StringBuilder html = new StringBuilder();
		html.append(valueToString(value));
		html.append("</textarea>");
		
		return html.toString();
	}
	
}
